package com.lmscn.lms.api.controller;

import java.util.HashMap;
import java.util.Map;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.lmscn.lms.api.model.Article;
import com.lmscn.lms.api.util.JsonKit;
import com.lmscn.lms.commons.GlobalConst;

public class ActicleController extends Controller {
	public void articleList() {
		Map<String, Object> dataMaps = new HashMap<String, Object>();
		Long categoryId = getParaToLong("categoryId");
		int pageNumber = getParaToInt("pageNumber");
		int pageSize = getParaToInt("pageSize");
		Page<Article> articlePage = Article.dao.getArticlePage(pageNumber, pageSize, categoryId);
		dataMaps.put("articleList", articlePage.getList());
		renderJson(JsonKit.mapToJson(dataMaps, GlobalConst.DEFAULT_DEPTH));
	}
	public void toDetailPage(){
		Long articleId = getParaToLong("articleId");
		setAttr("article", Article.dao.findById(articleId));
		renderJsp("/WEB-INF/jsp/wsdx/article_detail.jsp");
	}
	
	
}
